import { TypedUseSelectorHook, useSelector, useDispatch } from 'react-redux';
import { createStore } from 'redux';

import rootReducer from './reducer/index';

const store = createStore(rootReducer);

export type rootStateType = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

export const useAppSelector: TypedUseSelectorHook<rootStateType> = useSelector;

export const useAppDispatch = () => useDispatch<AppDispatch>();

export default store;
